using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;

namespace RawRestructure.Converters;

/// <summary>
/// 将布尔值转换为颜色的转换器
/// </summary>
public class BoolToColorConverter : IValueConverter
{
    /// <summary>
    /// 将布尔值转换为颜色
    /// </summary>
    /// <param name="value">布尔值</param>
    /// <param name="targetType">目标类型</param>
    /// <param name="parameter">参数</param>
    /// <param name="culture">文化信息</param>
    /// <returns>颜色</returns>
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is bool boolValue)
        {
            return boolValue ? Brushes.Green : Brushes.Gray;
        }
        
        return Brushes.Gray;
    }

    /// <summary>
    /// 将颜色转换回布尔值（不实现）
    /// </summary>
    /// <param name="value">颜色</param>
    /// <param name="targetType">目标类型</param>
    /// <param name="parameter">参数</param>
    /// <param name="culture">文化信息</param>
    /// <returns>布尔值</returns>
    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
} 